package com.luyishi.service.impl;

import com.luyishi.dao.UserMapper;
import com.luyishi.entity.User;
import com.luyishi.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Lenovo
 */
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> getUserInfo(){
        return userMapper.queryAllUser();
    }

    @Override
    public boolean register( String username,String password) {
        return (userMapper.addUser(username, password) > 0);
    }

    @Override
    public User login(String username, String password) {
        return userMapper.queryUserByUsernameAndPwd(username, password);
    }

    @Override
    public boolean repetitiveUsername(String username) {
        User user = userMapper.queryUserByUsername(username);
        return (user == null);
    }


}
